<nz-card>
  <!-- S 基础信息 -->
  <div class="form-item-wrap">
    <p class="item-title">
      <i nz-icon nzType="subnode" nzTheme="outline" class="t-icon"></i>
      基础信息
    </p>
    
    <div class="item-control">
      <nz-form-item>
        <nz-form-label nzFlex="120px" nzRequired>促销类型</nz-form-label>
        <nz-form-control nzFlex="400px">
          <nz-radio-group
            [(ngModel)]="formParams.type"
            (ngModelChange)="couponTypeChange($event)"
            [nzDisabled]="setDisabled()">
            <label nz-radio [nzValue]="2">百分比加价</label>
            <label nz-radio [nzValue]="1">固定加价</label>
          </nz-radio-group>
        </nz-form-control>
      </nz-form-item>

      <nz-form-item>
        <nz-form-label nzFlex="120px" nzRequired>前端名称</nz-form-label>
        <nz-form-control nzFlex="400px">
          <input
            nz-input
            maxlength="10"
            placeholder="请输入,前端用户可见"
            [(ngModel)]="formParams.showCopy"
            [disabled]="setDisabled()"
          />
        </nz-form-control>
      </nz-form-item>

      <nz-form-item>
        <nz-form-label nzFlex="120px">备注</nz-form-label>
        <nz-form-control nzFlex="400px">
          <nz-textarea-count [nzMaxCharacterCount]="30">
            <textarea
              rows="4"
              nz-input
              maxlength="30"
              placeholder="仅内部可见"
              [(ngModel)]="formParams.name"
              [disabled]="setDisabled()"
            ></textarea>
          </nz-textarea-count>
        </nz-form-control>
      </nz-form-item>

      <!-- <nz-form-item>
        <nz-form-label nzFlex="120px" nzRequired>总数量</nz-form-label>
        <nz-form-control>
          <div class="form-item-flex">
            <nz-input-number
              style="width: 120px;"
              [nzMin]="1"
              [nzMax]="100000"
              [nzStep]="1"
              [nzPrecision]="0"
              nzPlaceHolder="请输入"
              [(ngModel)]="formParams.total"
            ></nz-input-number>

            <span class="p-l-6">张</span>
          </div>
        </nz-form-control>
      </nz-form-item> -->

      <nz-form-item>
        <nz-form-label nzFlex="120px" nzRequired>加价条件</nz-form-label>
        <nz-form-control nzFlex="500px">
          <span class="p-r-6">单台机器回收价满</span>

          <nz-input-number
            style="width: 120px;"
            [nzMin]="0"
            [nzPrecision]="0"
            [nzStep]="1"
            nzPlaceHolder="请输入"
            [(ngModel)]="formParams.orderLimitMoney"
            [nzDisabled]="setDisabled()"
          ></nz-input-number>

          <span class="p-l-6 p-r-6">加价</span>

          <nz-input-number
            style="width: 120px;"
            [nzMin]="0.01"
            [nzPrecision]="2"
            [nzStep]="1"
            nzPlaceHolder="请输入"
            [(ngModel)]="formParams.limitSmall"
            [nzDisabled]="setDisabled()"
          ></nz-input-number>

          <span class="p-l-6" [hidden]="formParams.type === 1">%</span>

          <p class="condition-tip">说明：同一个订单只能享受一种加价，最少需一台机器满足条件</p>
        </nz-form-control>
      </nz-form-item>

      <nz-form-item *ngIf="formParams.type === 2">
        <nz-form-label nzFlex="120px" nzRequired>最高加价金额</nz-form-label>
        <nz-form-control>
          <div class="form-item-flex">
            <nz-input-number
              style="width: 120px;"
              [nzMin]="1"
              [nzMax]="100000"
              [nzStep]="1"
              [nzPrecision]="0"
              nzPlaceHolder="请输入"
              [(ngModel)]="formParams.limitBig"
              [nzDisabled]="setDisabled()"
            ></nz-input-number>

            <span class="p-l-6">元</span>
          </div>
        </nz-form-control>
      </nz-form-item>
    </div>
  </div>
  <!-- E 基础信息 -->

  <nz-divider></nz-divider>

  <!-- S 范围设置 -->
  <div class="form-item-wrap">
    <p class="item-title">
      <i nz-icon nzType="subnode" nzTheme="outline" class="t-icon"></i>
      范围设置
    </p>

    <div class="item-control">
      <nz-form-item>
        <nz-form-label nzFlex="120px" nzRequired>适用用户</nz-form-label>
        <nz-form-control nzFlex="400px">
          <nz-radio-group [(ngModel)]="formParams.userType" [nzDisabled]="setDisabled()">
            <label
              *ngFor="let o of userTypeOptions"
              nz-radio
              [nzValue]="o.value"
            >{{ o.label }}</label>
          </nz-radio-group>
        </nz-form-control>
      </nz-form-item>

      <!-- <nz-form-item>
        <nz-form-label nzFlex="120px" nzRequired>前端展示</nz-form-label>
        <nz-form-control nzFlex="400px">
          <nz-radio-group [(ngModel)]="formParams.isShowWeb">
            <label nz-radio [nzValue]="1">展示</label>
            <label nz-radio [nzValue]="0">不展示</label>
          </nz-radio-group>
        </nz-form-control>
      </nz-form-item> -->

      <nz-form-item>
        <nz-form-label nzFlex="120px" nzRequired>促销时间</nz-form-label>
        <nz-form-control nzFlex="500px">
          <nz-range-picker
            [nzShowTime]="true"
            [nzShowTime]="{ nzFormat: 'HH:mm:ss' }"
            nzFormat="yyyy-MM-dd HH:mm:ss"
            [(ngModel)]="receiveDates"
            (ngModelChange)="onDateChange($event, ['beginTime', 'endTime'])"
            [nzDisabled]="setDisabled()"
          ></nz-range-picker>

          <p class="condition-tip">说明：精确到秒，生效时间内前端才会展示该加价促销</p>
        </nz-form-control>
      </nz-form-item>

      <nz-form-item>
        <nz-form-label nzFlex="120px" nzRequired>规则说明</nz-form-label>
        <nz-form-control nzFlex="520px">
          <nz-textarea-count [nzMaxCharacterCount]="600">
            <textarea
              rows="10"
              nz-input
              maxlength="600"
              placeholder="请输入规则说明"
              [(ngModel)]="formParams.ruleExplain"
              [disabled]="setDisabled()"
            ></textarea>
          </nz-textarea-count>
        </nz-form-control>
      </nz-form-item>
    </div>
  </div>
  <!-- E 范围设置 -->
  
  <nz-divider></nz-divider>

  <!-- S 使用设置
  <div class="form-item-wrap">
    <p class="item-title">
      <i nz-icon nzType="subnode" nzTheme="outline" class="t-icon"></i>
      使用设置
    </p>

    <div class="item-control">
      <nz-form-item>
        <nz-form-label nzFlex="120px" nzRequired>有效期</nz-form-label>
        <nz-form-control nzFlex="400px">
          <nz-radio-group [(ngModel)]="effectiveType" (ngModelChange)="effectiveChange($event)">
            <label nz-radio [nzValue]="1">
              <span class="p-r-6">获得后</span>
              <nz-input-number
                [nzMin]="1"
                [nzStep]="1"
                [(ngModel)]="formParams.limitTimeNum"
                [nzDisabled]="effectiveType === 2"
              ></nz-input-number>
              <span class="p-l-6">天内有效</span>
            </label>

            <label nz-radio [nzValue]="2" class="m-t-15">
              <nz-range-picker
                [nzShowTime]="true"
                [nzShowTime]="{ nzFormat: 'HH:mm:ss' }"
                nzFormat="yyyy-MM-dd HH:mm:ss"
                [(ngModel)]="effectiveDates"
                (ngModelChange)="onDateChange($event, ['useBeginTime', 'useEndTime'])"
                [nzDisabled]="effectiveType === 1"
              ></nz-range-picker>
            </label>
          </nz-radio-group>
        </nz-form-control>
      </nz-form-item>

      <nz-form-item>
        <nz-form-label nzFlex="120px" nzRequired>规则说明</nz-form-label>
        <nz-form-control nzFlex="400px">
          <nz-textarea-count [nzMaxCharacterCount]="150">
            <textarea
              rows="4"
              nz-input
              maxlength="150"
              placeholder="请输入规则说明"
              [(ngModel)]="formParams.useDesc"
            ></textarea>
          </nz-textarea-count>
        </nz-form-control>
      </nz-form-item>
    </div>
  </div>
   E 使用设置 -->

  <!-- <nz-divider></nz-divider> -->

  <!-- S 适用机器 -->
  <div class="form-item-wrap">
    <p class="item-title">
      <i nz-icon nzType="subnode" nzTheme="outline" class="t-icon"></i>
      适用机器
    </p>

    <div class="item-control">
      <nz-form-item>
        <nz-form-label nzFlex="120px" nzRequired>适用成色</nz-form-label>
        <nz-form-control nzFlex="400px">
          <nz-radio-group [(ngModel)]="formParams.applyColour" [nzDisabled]="setDisabled()">
            <label
              *ngFor="let o of conditionOptions"
              nz-radio
              [nzValue]="o.value"
            >{{ o.label }}</label>
          </nz-radio-group>
        </nz-form-control>
      </nz-form-item>

      <nz-form-item>
        <nz-form-label nzFlex="120px" nzRequired>适用机型</nz-form-label>
        <nz-form-control nzFlex="400px">
          <p class="appoint-model">
            <label
              nz-radio
              [(ngModel)]="modelAll"
              [nzDisabled]="setDisabled()"
              (ngModelChange)="modelOwnerAllChange($event)"
            >全选</label>
          </p>
          <div class="p-t-6">
            已选
            <b *ngIf="modelAll;else templateAll">
              全部
            </b>
            <ng-template #templateAll>
              <b>{{ defaultModelKeys?.length || 0 }}</b> 个
            </ng-template>
            机型
            <button
              nz-button
              nzType="link"
              [disabled]="setDisabled()"
              (click)="selectMoreModel()"
            >选择更多</button>

            <!-- select-tree -->
            <model-select-tree
              [defaultKeys]="defaultModelKeys"
              [(ngModel)]="isModelVisible"
              (onSubmit)="subModelTree($event)"
            ></model-select-tree>
          </div>
        </nz-form-control>
      </nz-form-item>
    </div>
  </div>
  <!-- E 适用机器 -->
</nz-card>

<nz-card class="m-t-4">
  <div nz-row nzJustify="center" nzAlign="top">
    <button
      [hidden]="formParams.status !== 5 && !['3'].includes(routeParams.type)"
      nz-button
      nzType="primary"
      class="m-r-10"
      [nzLoading]="releaseLoading"
      (click)="releaseCoupon()"
    >发布</button>

    <button
      [hidden]="[3, 4].includes(formParams.status) && !['0', '3'].includes(routeParams.type)"
      nz-button
      nzType="primary"
      class="m-r-10"
      [nzLoading]="sumitLoading"
      (click)="submitForms()"
    >保存</button>
    
    <button
      nz-button
      nzType="dashed"
      (click)="back()"
    >返回</button>
  </div>
</nz-card>